# -*- coding = utf-8 -*-
# @Time    : 2025/3/28 下午8:06
# @Author  : yqk
# @File    : 多线程2.py
# @Software: PyCharm

import threading
import time

class Singing(threading.Thread):
    def __init__(self,delay):
        super(Singing,self).__init__()
        self.delay = delay
    def run(self) -> None:
        print(f'{threading.current_thread().name}开始唱歌')
        time.sleep(self.delay)
        print('结束唱歌')
class Dancing(threading.Thread):
    def __init__(self,delay):
        super(Dancing,self).__init__()
        self.delay = delay
    def run(self) -> None:
        print(f'{threading.current_thread().name}开始跳舞')
        time.sleep(self.delay)
        print('结束跳舞')

def multi_thread():
    task = []
    t1 = Singing(2)
    t1.start()
    task.append(t1)
    for i in range(3):
        t2 = Dancing(4)
        t2.start()
        task.append(t2)

    for t in task:
        t.join()

if __name__ == '__main__':
    st_time = time.time()
    multi_thread()
    end_time = time.time()
    print(f'耗时：{end_time - st_time}')